
package com.cptravel.tool;

import java.util.regex.Pattern;

public class VerifyData
{
    public static boolean verifyUserName(String userName)
    {
        return verify(userName, "\\w{4,}");
    }

    public static boolean verifyPwd(String pwd)
    {
        return verify(pwd, "\\w{6,}");
    }

    public static boolean verifyPhone(String phoneNumber)
    {
        return verify(phoneNumber, "^[1][3,4,5,7,8][0-9]{9}$");
    }

    public static boolean verifyEmail(String email)
    {
        return verify(email, "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    }

    public static boolean verify(String string , String patternStr)
    {
        Pattern pattern = Pattern.compile(patternStr);
        return pattern.matcher(string).matches();
    }
}
